Skip to content

Conversation

@d-munday
Copy link

No description provided.

Copy link
Contributor

@JacoBriers JacoBriers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments:

  • I like the look and feel, nice and clean
  • On the navigation: splitting the search and navigate-to-page functionality that you provide with the "Enter ID" input into two inputs, may make it a bit clearer to the user what they are for.
  • Code neatness needs a little work: consistent use of tabs and spaces, use of white-space between variables and operators, etc. There are plugins for IDEs that will help you out here.
    Well done!

app.ts Outdated
function buildTable(columns, records) {

// create table
let table = document.createElement("table");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistently use tabs/spaces for formatting. We set up VSCode for our projects to auto-format our code, so this isn't usually a problem, but if you don't have help from the IDE you have to do it manually. Formatting-war is a real thing and we do all we can to prevent it :)

app.ts Outdated
table.appendChild(thead);

// create rows
records.forEach(function (el) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather use for of loop or old fashioned for loop

app.ts Outdated
// debounce function to reduce frequency of queries made
window.onresize = () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

app.ts Outdated
record.style.display="block";
if(td){
let val = td.innerText || td.textContent;
if(val.indexOf(input) > -1){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't overuse ternary statements but here you could:

record.style.display = val.indexOf(input) === -1 ? "none" : "";

app.ts Outdated
loader.innerHTML=`<div class="loader" id="loader"></div>`;

// outter function to fetch column headers from server
$.get("http://localhost:2050/columns", function(columns){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call will always return the same values, so you can call it once and cache the results, like you did with record count.

app.css Outdated
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this on Safari?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I didn't - will remove it for now since it's not necessary to include.

app.ts Outdated
if(e.which == 13)
{
let end = parseInt(input) + calculateRows();
clearTable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you always clearTable before you loadPage you can move clearPage inside loadPage

app.ts Outdated
}

// loads the columns and rows to be displayed based on start and end row indices
function loadPage(start:number, end:number){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make this take only the start index and then you add caclulateRows() inside this method to calc the end index.


// filters rows by user input ID
function search(e){
let input = $("#search").val().toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't a problem here, but when working in the codebase for our other projects, you will need to use more specific div IDs since they are in a "global namespace" of sorts and could conflict with the naming of existing divs.

@d-munday
Copy link
Author

Thanks for the feedback, Jaco - will submit another pull request in due course once every recommendation has been accounted for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants